<!DOCTYPE html>
<html lang="en">
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/resource/common/layui/css/layui.css">
    <link rel="stylesheet" href="/resource/js/front/index.css">
</head>
<style>
    .house-userPer .user-person ul li {
        width: 214px
    }

    .editInfo {
        width: 100%;
        height: 110px;
        color: #84a3bf;
        border: none;
        border-radius: 0;
        border-right: 1px solid #e6e6e6;
        border-left: 1px solid #e6e6e6;
        border-bottom: 1px solid #e6e6e6;
    }
</style>
<body>
<div th:replace="front/head :: heads"></div>
<div class="layui-container userpublic house-userPer">
    <div class="layui-row layui-col-space20">
        <p class="layui-hide-xs title">首页 &gt; <span>个人信息</span></p>
        <div th:replace="front/head :: info-nav"></div>
        <div class="layui-col-sm10">
            <div class="user-person">
                <div class="person">
                    <img th:src="${userInfo.imgUrl}">
                    <div class="name">
                        <p th:text="${userInfo.userName}">小明1988</p>
                        <span th:if="${userInfo.userRank eq '0'}"><i>普通用户</i></span>
                        <span th:if="${userInfo.userRank eq '1'}"><i>会员</i></span>
                    </div>
                </div>
                <ul>
                    <li>真实姓名<span th:text="${userInfo.realName}"></span></li>
                    <li>邮件<span th:text="${userInfo.email}"></span></li>
                    <li>联系地址<span th:text="${userInfo.address}"></span></li>
                    <li>性别<span th:text="${userInfo.sex}"></span></li>
                    <li>联系电话<span th:text="${userInfo.iphone}"></span></li>
                </ul>
            </div>
            <button class="layui-btn layui-btn-primary editInfo"><i class="layui-icon layui-icon-edit">修改信息</i>
            </button>

            <div class="layui-form updataUser" action="" style="margin:auto;margin-top:10px;display: none">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">用户名</label>
                        <div class="layui-input-inline">
                            <input id="userName" name="userName" th:value="${userInfo.userName}" lay-verify="required"
                                   class="layui-input"/>
                            <input id="id" name="id" th:value="${userInfo.id}" hidden/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">联系地址</label>
                        <div class="layui-input-inline">
                            <input id="address" name="address" th:value="${userInfo.address}" class="layui-input"/>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">真实姓名</label>
                        <div class="layui-input-inline">
                            <input id="realName" value="" th:value="${userInfo.realName}"
                                   name="realName"
                                   lay-verify="required"
                                   class="layui-input"/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">性别</label>
                        <div class="layui-input-inline">
                            <select name="sex">
                                <option th:selected="${userInfo.sex} eq '男'">男</option>
                                <option th:selected="${userInfo.sex} eq '女'">女</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">手机号</label>
                        <div class="layui-input-inline">
                            <input id="iphone" name="iphone" th:value="${userInfo.iphone}" class="layui-input"
                                   lay-verify="phone"/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">电子邮件</label>
                        <div class="layui-input-inline">
                            <input id="email" name="email" th:value="${userInfo.email}" class="layui-input"
                                   lay-verify="email"/>
                        </div>
                    </div>
                </div>
                <div class="notice_bot">
                    <div class="r_right but_p" style="text-align: center">
                        <button class="but_save layui-btn" lay-submit="" lay-filter="Submit"
                                style="padding: 0;width: 100px">保存
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- layui.js -->
<script type="text/javascript" src="/resource/common/layui/layui.js"></script>
<script type="text/javascript" src="/resource/js/front/house.js"></script>
<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
<!--[if lt IE 9]>
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
    layui.use(['table', 'layer', 'laydate', 'form'], function () {
        var table = layui.table,
            $ = layui.$,
            layer = layui.layer,
            form = layui.form
        $('.editInfo').on('click', function () {
            $('.updataUser').show()
        })
        form.on('submit(Submit)', function (data) {
            $.ajax({
                url: '/user/user.do',
                type: 'put',
                data: data.field,
                dataType: 'json',
                async: false,
                success: function (result) {
                    if (result.status) {
                        layer.alert("编辑成功!", {
                            time: 1000,
                            end: function () {
                                location.reload()
                            }
                        })
                    } else {
                        layer.msg("编辑成功失败!");
                    }
                }

            });
        });
    });
</script>

</body>
</html>